{% extends "base.html" %}
{% block content %}
{% ifequal is_con 0 %}
<script type="text/javascript" src="/static/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="/static/js/jquery-ui-1.8.16.custom.min.js"></script>
<link href="/static/css/jquery-ui-1.8.16.custom.css" rel="stylesheet" type="text/css" />
<div class="form-div" style="margin:10px;">
  <form action='' method='get' name="searchForm">
	<table>
		<tr>
			<td style="border:0px;padding:3px;">
				<img src="/static/images/icon_search.gif" width="26" height="22" border="0" alt="SEARCH">
			</td>
			<td  style="border:0px;padding:3px;">
				Program:<select name="p_id" id="p_id" style="color:#CC33FF" onchange='$("#stu_name").attr("name","");$("input#search").click()'>
							{% for p in project_list %}
								<option value="{{p.id}}" {% ifequal p.id p_id %} selected="selected" {% endifequal %}>{{p.name}}</option>
							{% endfor %}
							</select>
							<select name="stu_name_id" id="stu_name" style="color:#CC33FF" onchange='$("input#search").click()'>
							</select>
				<input type='button' id="search" value='Search'/>
			</td>
		</tr>
	</table>
  </form>
</div>
<script type="text/javascript" src="/static/js/create_report_export.js"></script>
<script>
$("input#search").bind({
	click:function(){
		var t = this
		if(t.style.cursor == 'wait'){
			return false;
		}
		t.style.cursor = 'wait'
		var data = $('form[name="searchForm"]').serializeArray()
		var datas = {'is_con':1,'t':Math.random()}
		for(var i=0;i<data.length;i++){
			datas[data[i].name] = data[i].value
		}
		$.ajax({
			url:'',
			data:datas,
			type:'get',
			dataType:'html',
			success:function(e){
				t.style.cursor = 'pointer'
				$('#conreturn').html(e)
			}
		})
	}
})
</script>
{% endifequal %}
<style>
td{
	padding:2px;
	border:1px dotted #333;
}
th{
	background:#ffffcd;
	border:1px dotted #333;
	padding:2px;
	line-height:30px;
}
.selectdate{
	width:auto;float:left;padding:3px;background:#fff;border:1px dotted #333;margin:2px;cursor:pointer;
}
.selectdate:hover{
	background:#defdef;
}
.gray{
	color:gray;
}
</style>
<div id="conreturn" style="margin:10px;">
	{%if error_info%}
		<span class='red'>{{error_info}}</span>
	{%else%}
	<table width='90%'>
		<tr>
			<td style="border:1px solid #333;">
				<table width='100%'>
				  <tr>
					<td colspan='2' align='left' style="line-height:25px;background:#ffffcd;border:0px;padding:3px;"></td>
					<td align='right' colspan='5' align='right' style="line-height:25px;background:#ffffcd;border:0px;padding:3px;">
						<strong><span id='university'></span></strong><br>
						<strong><span id='program'></span></strong>
					</td>
				  </tr>
				  <tr>
					<td colspan='7' align='left' style="line-height:25px;background:#ffffcd;border:0px;padding:3px;font-size:20px;"><strong id='report_title'>Student Individual Study Plan</strong></td>
				  </tr>
				</table>
			</td>
		</tr>
		{%if stu_names%}
		<tr><td>
			<table width="100%">
				<tr><td width="80px">Name:</td><td colspan="4" align='left'><span id="fullname"></span></td></tr>
				<tr><td width="80px">Tel.#:</td><td colspan="4" align='left'><span id="tel"></span></td></tr>
				<tr><td width="80px">Email:</td><td colspan="4" align='left'><span id="email"></span></td></tr>
				<tr><td width="80px">Mailing Address:</td><td colspan="4" align='left'><span id="Mailing"></span></td></tr>
				<tr><td width="80px">Start Date:</td><td colspan="4" align='left'><span id="start_date"></span></td></tr>
			</table>
			</td>
		</tr>
		<tr height="25"><td></td></tr>
		<tr><td>
			<table width='100%'>
				<tr>
					<th>Modules</th>
					<th width="130px">Core / Elective</th>
					<th width="450px">Class Date </th>
					<th width="70px">Supposed</th>
					<th width="80px">Status</th>
				</tr>
				{%if module_ret%}
				{%for m in module_ret%}
				<tr>
					<td>{{m.0}}</td>
					<td align="center">{{m.1}}</td>
					<td>
						{%if m.2%}{{m.2|date:'M d,Y'}}{%endif%}
						{%if m.3%}&nbsp;/&nbsp;{{m.3|date:'M d,Y'}}{%endif%}
						{%if m.4%}&nbsp;/&nbsp;{{m.4|date:'M d,Y'}}{%endif%}
						{%if m.5%}&nbsp;/&nbsp;{{m.5|date:'M d,Y'}}{%endif%}
						{%if m.6%}&nbsp;/&nbsp;{{m.6|date:'M d,Y'}}{%endif%}
					</td>
					<td></td>
					<td>
						<font color={%ifequal m.7 'Completed'%}"green"{%else%}"gray"{%endifequal%}>{{m.7|capfirst}}</font>
					</td>
				</tr>
				{%endfor%}
				{%else%}
				<tr>
					<td colspan='5' align='center'><span style="color:green;font-size:16px;line-height:30px;">No Result!</span></td>
				</tr>
				{%endif%}
			</table>
		</td></tr>
		<tr height="25"><td></td></tr>
		<tr>
			<td align="center">
				<table align="center">
					<tr>
						<th colspan="5">Payment Schedule</th>
					</tr>
					<tr>
						<td style="background:#defdef;"></td>
						<td style="background:#defdef;width:120px;" align='center'>Amount</td>
						<td style="background:#defdef;width:120px;" align='center'>Due Date</td>
						<td style="background:#defdef;width:120px;" align='center'>Paid Date</td>
						<td style="background:#defdef;width:120px;" align='center'>Paid By</td>
					</tr>
					{%if pay_list%}
					<tr>
						<td>App Fee</td>
						<td>{%if pay_list.datefee_money%}{{pay_list.moneytypedatefee}}:{{pay_list.datefee_money}}{%endif%}</td>
						<td>{{pay_list.datefee_invoice}}</td>
						<td>{{pay_list.datefee_paid}}</td>
						<td>{{pay_list.datefee_paiy_by}}</td>
					</tr>
					<tr>
						<td>1st installment</td>
						<td>{%if pay_list.date1_money%}{{pay_list.moneytypedate1}}:{{pay_list.date1_money}}{%endif%}</td>
						<td>{{pay_list.date1|date:"M d,Y"}}</td>
						<td>{{pay_list.date1_paid|date:"M d,Y"}}</td>
						<td>{{pay_list.date1_paiy_by}}</td>
					</tr>
					<tr>
						<td>2st installment</td>
						<td>{%if pay_list.date2_money%}{{pay_list.moneytypedate2}}:{{pay_list.date2_money}}{%endif%}</td>
						<td>{{pay_list.date2|date:"M d,Y"}}</td>
						<td>{{pay_list.date2_paid|date:"M d,Y"}}</td>
						<td>{{pay_list.date2_paiy_by}}</td>
					</tr>
					<tr>
						<td>3st installment</td>
						<td>{%if pay_list.date3_money%}{{pay_list.moneytypedate3}}:{{pay_list.date3_money}}{%endif%}</td>
						<td>{{pay_list.date3|date:"M d,Y"}}</td>
						<td>{{pay_list.date3_paid|date:"M d,Y"}}</td>
						<td>{{pay_list.date3_paiy_by}}</td>
					</tr>
					<tr>
						<td>4st installment</td>
						<td>{%if pay_list.date4_money%}{{pay_list.moneytypedate4}}:{{pay_list.date4_money}}{%endif%}</td>
						<td>{{pay_list.date4|date:"M d,Y"}}</td>
						<td>{{pay_list.date4_paid|date:"M d,Y"}}</td>
						<td>{{pay_list.date4_paiy_by}}</td>
					</tr>
					<tr>
						<td>TL:</td>
						<td colspan='4'>{{tolmoney}}</td>
					</tr>
					{%else%}
					<tr>
						<td colspan='10' align="center"><span style="color:green;font-size:16px;line-height:30px;">No Result!</span></td>
					</tr>
					{%endif%}
				</table>
			</td>
		</tr>
		{%else%}
		<tr>
			<td colspan='10' align="center"><span style="color:green;font-size:16px;line-height:30px;">No Result!</span></td>
		</tr>
		{%endif%}
	</table>
	{%endif%}
</div>
{{ttt}}
<script>
var stu_name = ''
{%if stu_names%}
	$('#stu_name').show()
	{% for p in stu_names %}
		stu_name += '<option value="{{p.0}}" {%ifequal p.0 stu_name_id%} selected {%endifequal%}>{{p.1}}</option>'
		{%ifequal p.0 stu_name_id%}
			{%if p.1%}
				$('#fullname').html('{{p.1}}')
			{%else%}
				$('#fullname').html('{{p.2}}')
			{%endif%}
			$('#tel').html('{{p.3}}'+'<br>'+'{{p.4}}'+'<br>'+'{{p.5}}')
			$('#email').html('{{p.6}}'+'<br>'+'{{p.7}}')
			$('#start_date').html('{{p.8|date:'M Y'}}')
			$('#Mailing').html('{{p.9}}'+'<br>'+'{{p.10}}')
		{%endifequal%}
	{% endfor %}
{%else%}
	$('#stu_name').hide()
{%endif%}
$('#stu_name').html(stu_name);
$('#stu_name').attr('name',"stu_name_id")
var pro = parseInt($('#p_id').val())
if(school[pro]!=undefined){
	$('#university').text(school[pro][0])
	$('#program').text(school[pro][1])
}
</script>
{% endblock %}
